package com.swagger.gitee.swagger;

import java.util.ArrayList;
import java.util.List;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(value = "api  demo 演示")
@RestController
public class TestController {

	@ApiOperation(value = "apitest3", notes = "json嵌套三层解析示例", httpMethod = "POST")
	@RequestMapping(value = "/apitest3", method = RequestMethod.POST,produces = { "application/json; charset=utf-8" })
//	@ApiImplicitParams({
//		@ApiImplicitParam(
//		name="requestItem",value="测试",required = true,
//		dataType = "RequestItem«第三层值对象»",
//		paramType = "body")})
	public ResponseItem<PageItem<ThirdItem>> apidocdemo3(@RequestBody RequestItem<PageItem<ThirdItem>> requestItem) {
		ResponseItem<PageItem<ThirdItem>> responseItem = new ResponseItem<PageItem<ThirdItem>>();
		responseItem.setCode("1");
		responseItem.setMessage("处理成功");
		responseItem.setSign("aaa");
		responseItem.setSignType("sm2");
		ThirdItem thirdLayerItem = new ThirdItem();
		thirdLayerItem.setData("第三层内容");
		thirdLayerItem.setId(11);
		List<ThirdItem> list = new ArrayList<ThirdItem>();
		list.add(thirdLayerItem);
		PageItem pageItem = new PageItem();
		pageItem.setDatalist(list);
		responseItem.setData(pageItem);
		return responseItem;
	}

	@ApiOperation(value = "apitest2", notes = "json嵌套二层解析", httpMethod = "POST")
	@RequestMapping(value = "/apitest2", method = RequestMethod.POST)
	public ResponseItem<SecondItem> apidocdemo2(@RequestBody RequestItem<SecondItem> requestItem) {
		ResponseItem<SecondItem> responseItem = new ResponseItem<SecondItem>();
		responseItem.setCode("1");
		responseItem.setMessage("处理成功");
		responseItem.setSign("aaa");
		responseItem.setSignType("sm2");
		SecondItem secondLayerItem = new SecondItem();
		secondLayerItem.setData("第二层内容");
		secondLayerItem.setId(11);
		responseItem.setData(secondLayerItem);
		return responseItem;
	}
}
